<template>
  <div id="app">
    <Topbar :key="gaib"></Topbar>
    <Header></Header>
    <router-view @updateKey="updateKeyfn" />
    <Footer></Footer>
    <Login v-show="isshowLoginModal"></Login>
    <transition name="slide">
      <Toast v-show="istoastS"></Toast>
    </transition>
  </div>
</template>
<script>
//引入组件
import Topbar from "./components/Topbar.vue";
import Header from "./components/Header.vue";
import Footer from "./components/Footer.vue";
import Login from "./components/Login.vue";
import Toast from "./components/Toast.vue";
import { JingPinAPI, ReMenAPI } from "@/request/api";
import { mapState } from "vuex";
export default {
  //注册组件
  components: {
    Topbar,
    Header,
    Footer,
    Login,
    Toast,
  },
  data() {
    return {
      gaib: 0,
    };
  },
  methods: {
    updateKeyfn() {
      this.gaib++;
    },
  },
  async created() {
  //  console.log("环境",process.env.VUE_APP_BASE_URL);
  //  console.log("环境",process.env.VUE_APP_MY_NAME);
  },
  computed: {
    ...mapState({
      isshowLoginModal: (state) => state.showmodal.isShowlogin,
      istoastS: (state) => state.istoasts.istoast,
    }),
  },
  watch: {
    "$route.path": {
      handler(newval, olval) {
        if (olval != "/") {
          this.gaib++;
        }
      },
    },
  },
};
</script>
<style lang="less">
/* 入场的起始状态=离场的结束状态 */
.slide-enter,
.slide-leave-to {
  opacity: 0;
}
.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}
.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
